package com.inventory.api.entity;


import com.inventory.api.signUpReq.StockCheckSignUpReq;
import com.inventory.api.util.UuidUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;

/**
 * 盘点记录
 * Created by hanxi on 2017/8/1.
 */
@Entity
@Data
@NoArgsConstructor
public class StockCheckTransaction {
    @Id
    @Column(length = 50)
    private String id;
    private String productId;
    private String productName;
    private String storeId;

    /**
     * 盘点ID
     */
    private String checkOrderId;

    /**
     * 实际总个数量
     */
    private int checkSingleQty;

    /**
     * 实际总件数
     */
    private int checkWholeQty;

    /**
     * 应有个数
     */
    private int accurateSingleQty;

    /**
     * 应有件数
     */
    private int accurateWholeQty;

    /**
     * 操作人
     */
    private String operatorId;


    private String operatorName;

    /**
     * 规格
     */
    private int stockQuantityRatio = 1;


    /**
     * 备注
     */
    private String notes;

    /**
     * 操作时间
     */
    @Column(columnDefinition = "TIMESTAMP(3) NULL")
    private Date operTime;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3)")
    private Date addTime;

    public StockCheckTransaction(String checkOrderId, String storeId, String operatorId,
                                 String operatorName, StockCheckSignUpReq.CheckProduct product) {
        id = UuidUtil.getUuid();
        productId = product.getProductId();
        productName = product.getProductName();
        this.storeId = storeId;
        checkSingleQty = product.getCheckSingleQty();
        checkWholeQty = product.getCheckWholeQty();
        accurateSingleQty = product.getAccurateSingleQty();
        accurateWholeQty = product.getAccurateWholeQty();
        this.operatorId = operatorId;
        this.operatorName = operatorName;
        operTime = new Date();
        notes = product.getNotes();
        stockQuantityRatio = product.getStockQuantityRatio();
        this.checkOrderId = checkOrderId;
    }
}
